<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const input = document.createElement('input')
      //   input.focus() // 此时,input还没有插入页面,所以获取焦点不会生效
      document.body.appendChild(input)
      input.focus()
    </script>
  </body>
</html>
